import React from 'react'
import { SimpleSelector } from './simpleSelector'
import { WaitShowOrHideTypes } from '../../common/enums'

export const WaitShowOrHideTypeSelector = ({ inputClassName, initValue, onSelectItem, readOnly }) => {
    const dataSource = [
        { code: WaitShowOrHideTypes.Show, remark: '显示' },
        { code: WaitShowOrHideTypes.Hide, remark: '隐藏' }
    ].filter(Boolean)
    const filterDataSource = React.useCallback(value => item => item.code === value.toUpperCase() || item.remark.includes(value), [])
    const getItemValue = React.useCallback(item => item.code, [])
    const renderItem = React.useCallback(item => `${item.code}[${item.remark}]`, [])

    return <SimpleSelector inputClassName={inputClassName} dataSource={dataSource} filterDataSource={filterDataSource}
        getItemValue={getItemValue} initValue={initValue} onSelectItem={onSelectItem}
        readOnly={readOnly} renderItem={renderItem} />
}